class Solution(object):
    def getWinner(self, arr, k):
        max_val = max(arr)
        n = len(arr)
        if k >= n - 1:
            return max_val
        now_max = arr[0]
        if now_max == max_val:
            return now_max
        c = 0
        for i in range(1, n):
            if now_max > arr[i]:
                c += 1
                if c == k:
                    return now_max
            else:
                now_max = arr[i]
                c = 1
                if now_max == max_val or c == k:
                    return now_max
